package cn.angis.flow.adapter;

import cn.angis.system.dto.output.LoginOutput;
import cn.angis.system.model.Role;
import cn.angis.system.model.AngisUser;
import org.dromara.warm.flow.core.enums.CooperateType;
import org.dromara.warm.flow.core.service.TaskService;
import org.dromara.warm.flow.core.utils.StreamUtils;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;

import java.util.List;

@Component
public abstract class AbstractWarmFlowAdapter {
    @Inject
    protected TaskService taskService;

    /**
     * 获取权限
     *
     * @return 权限列表
     */
    protected List<String> permissionList(LoginOutput loginOutput, String userId) {
        List<Role> roles = loginOutput.getRoles();
        List<String> permissionList = StreamUtils.toList(roles, role -> "role:" + role.getId());
        permissionList.add(userId);
        permissionList.add("dept:" + loginOutput.getDeptId());
        return permissionList;
    }

    /**
     * 根据类型获取描述
     *
     * @param type 流程类型
     * @return value
     */
    protected String type(Integer type) {
        return CooperateType.getValueByKey(type);
    }
}
